# -*- coding: utf-8 -*-
# @Time : 2022/1/6 14:14
# @Author : Limusen
# @File : unittest_demo_20

import os
import unittest
from common import HTMLTestReportCN

case_path = os.path.dirname(os.path.abspath(__file__))


def get_all_case():
    discover = unittest.defaultTestLoader.discover(start_dir=case_path,  # 测试用例的地址
                                                   pattern="unittest_demo_20.py",  # 以什么样的文件名去搜索
                                                   top_level_dir=None)
    suite = unittest.TestSuite()
    suite.addTest(discover)
    report_dir = HTMLTestReportCN.ReportDirectory("D:\PythonSelenium\\reports\\")
    report_dir.create_dir("ui自动化测试报告")
    report_path = HTMLTestReportCN.GlobalMsg.get_value('report_path')
    dir_path = HTMLTestReportCN.GlobalMsg.get_value('dir_path')
    fp = open(report_path, 'wb')
    runner = HTMLTestReportCN.HTMLTestRunner(stream=fp,
                                             title="ui自动化",
                                             description="测试一下",
                                             tester="li")
    runner.run(suite)


if __name__ == '__main__':
    get_all_case()
